/**
 * 
 */
package npap.cater.unr.edu.client.scaffold.place.customized;

import org.apache.commons.io.input.ProxyInputStream;

import npap.cater.unr.edu.client.proxy.ProjectProxy;
import npap.cater.unr.edu.client.scaffold.place.ProxyListPlace;
import npap.cater.unr.edu.client.scaffold.place.ProxyPlace;
import npap.cater.unr.edu.client.scaffold.place.ProxyPlace.Operation;
import npap.cater.unr.edu.client.scaffold.place.ProxyPlaceToListPlace;

import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceTokenizer;
import com.google.gwt.place.shared.Prefix;
import com.google.web.bindery.requestfactory.shared.EntityProxy;
import com.google.web.bindery.requestfactory.shared.EntityProxyId;
import com.google.web.bindery.requestfactory.shared.RequestFactory;

/**
 * @author Hao
 *
 */
public class ProjectListPlace extends Place{
	/**
	 * @uml.property  name="projectName"
	 */
	private final String projectName;
	/**
	 * @uml.property  name="idProject"
	 */
	private  Integer idProject;
//	private  ProxyPlace proxyPlace;
	

	/**
	 * Tokenizer.
	 */
	@Prefix("p")
	public static class Tokenizer implements PlaceTokenizer<ProjectListPlace> {
		private static final String SEPARATOR = "!";

		public Tokenizer(RequestFactory requests) {
		}

		public ProjectListPlace getPlace(String token) {

			String bits[] = token.split(SEPARATOR);
			
			ProjectListPlace projectListPlace=new ProjectListPlace(Integer.valueOf(bits[0]),bits[1]);
			
			return projectListPlace;
		}


		@Override
		public String getToken(ProjectListPlace place) {
			// TODO Auto-generated method stub
			return place.getIdProject().toString()+SEPARATOR+place.getProjectName();
		}
		
		

		
	}

	

	
	/**
	 * @return
	 * @uml.property  name="projectName"
	 */
	public String getProjectName() {
		return projectName;
	}
	/**
	 * @return
	 * @uml.property  name="idProject"
	 */
	public Integer getIdProject() {
		return idProject;
	}


//	public ProxyPlace getProxyPlace() {
//		return proxyPlace;
//	}
//	public void setProxyPlace(ProxyPlace proxyPlace) {
//		this.proxyPlace = proxyPlace;
//	}

	/**
	 * @param idProject
	 * @uml.property  name="idProject"
	 */
	public void setIdProject(Integer idProject) {
		this.idProject = idProject;
	}

	public ProjectListPlace(Integer id, String projectName)
	{
		this.projectName=projectName;
		this.idProject=id;
	}


	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof ProjectListPlace)) {
			return false;
		}
		if (this == obj) {
			return true;
		}
		ProjectListPlace other = (ProjectListPlace) obj;
		return (this.idProject.equals(other.getIdProject())&&this.projectName.equals(other.getProjectName()));
	}

	

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + getIdProject().hashCode();
		result = prime * result + getProjectName().hashCode();
		
		return result;
	}

	@Override
	public String toString() {
		return "ProjectListPlace ["+getProjectName()+"]idproject=" + getIdProject() +"]";
	}
}
